<?php
namespace App\Repositories\Main;

use App\Models\Main\BaleCostModel;
use App\Repositories\BaseRepository;

class BaleCostRepository extends BaseRepository
{
    protected $repository;

    public function __construct()
    {
        $this->repository = new BaleCostModel();
    }

    public function setAdd($data)
    {
        $data['created_at'] = time();
        return $this->repository->insertGetId($data);
    }

//    public function setModify($data,$id)
//    {
//        $data['updated_at'] = time();
//        return $this->repository->where('id',$id)
//            ->update($data);
//    }

    public function setModifyName($id,$name)
    {
        $data['name'] = $name;
        $data['updated_at'] = time();
        return $this->repository->where('id',$id)
            ->update($data);
    }

    public function setModifyCost($id,$cost)
    {
        $data['cost'] = $cost;
        $data['updated_at'] = time();
        return $this->repository->where('id',$id)
            ->update($data);
    }

    public function getShowOne($id)
    {
        return $this->repository->where('id',$id)->first();
    }

    public function getShowByType($type)
    {
        return $this->repository
            ->where('type',$type)
            ->get();
    }

    public function getShowByType2($type,$name)
    {
        return $this->repository
            ->where('type',$type)
            ->where('name',$name)
            ->first();
    }
}